import request from "@/utils/request";

// 初始化剧本
export const initializeScriptService = (conversationID, scriptId) => {
    return request.post('/AIClient/initialize', {conversationID,scriptId},
        {
            headers: {
                'Content-Type': 'application/json'  // 使用 application/json
            }
        });
}

// 向 AI 提问
export const askAIService = (conversationID,userID, content, status) => {
    return request.post('/AIClient/ask',
        {conversationID,userID, content, status},
        {
            headers: {
                'Content-Type': 'application/json'  // 使用 application/json
            }
        });
}

// 获取用户的历史对话
export const getUserConversationsService = (userId) => {
    return request.get(`/conversation/list/${userId}`, {
        headers: {
            'Content-Type': 'application/json'
        }
    });
};

// 获取某个对话的对话信息
export const getConversationMessagesService = (conversationId, userId) => {
    return request.get(`/conversation/messages/${conversationId}`, {
        params: {user_id: userId},
        headers: {
            'Content-Type': 'application/json'
        }
    });
};

//创建对话
export const createConversationService = (user_id, script_id) => {
    const params = new URLSearchParams();
    params.append('user_id', user_id);
    params.append('script_id', script_id);
    return request.post('/conversation/create', params, {
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    });
};

//删除对话
export const deleteConversationService = (id) => {
    return request.delete(`/conversation/delete/${id}`);
};


